/* Autostop
 *
 * Copyright (c) Maciej Gajewski, Grzegorz Latarowski
 * http://code.google.com/p/autostop-automaty-drogowe
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version. NO WARRANTY OF ANY KIND is expressed or implied.
 */

#ifndef CAMERA_H
#define CAMERA_H

// includes
#include <asm/ioctl.h>
#ifdef __KERNEL__
	#include <linux/types.h>
#else
	#include <stdint.h>
#endif

// NOTE: keep naming convention here, all identifiers should start with 'camera_' prefix
// lowercase for structs and uppercase for defines

// ioctl defines (do not use directly)
#define CAMERA_IOC_MAGIC	'p'

// ============================================================================
// IOCTL COMMANDS

// cs0 16-bit register access
#define CAMERA_CS0_READ		_IOW( CAMERA_IOC_MAGIC, 3, void* )
#define CAMERA_CS0_WRITE		_IOW( CAMERA_IOC_MAGIC, 4, void* )

// multiple read register access
#define CAMERA_CS0_READ_HIBYTES	_IOW( CAMERA_IOC_MAGIC, 5, void* )	// reads high ords from multiple bytes
#define CAMERA_CS0_READ_MULTI	_IOW( CAMERA_IOC_MAGIC, 6, void* )	// reads multiple bytes fro mregisters, entire words

/// structure used in register access ioctl commands
struct camera_register {
	uint32_t address;	///< register address, in words, shift from CS0
	uint32_t value;		///< value. only lower 16 bits are used
	};
	
/// structure used in multiple reads of byte-size values
struct camera_multiple_bytes {
	uint32_t address;	///< register address, in words, shift from CS0
	uint32_t count;		///< numebnr of bytes to read
	uint8_t* buffer;	///< buffer for readed values
	};

// ============================================================================
// DEVICE NUMBERS

// major device number
#define CAMERA_DEV_MAJOR		222
// minor number - firmwarewriting dev
#define CAMERA_DEV_FIRMWARE		0

#endif // CAMERA_H

// eof 


